package cn.edu.scau.cmi.wuzewei.composite.safe;

import java.util.HashMap;
import java.util.Map;

public class SafeComposite implements SafeComponent {
	public String name;
	
	@Override
	public String doSomething() {

		return null;
	}
	
	@Override
	public String toString() {
		return name;
	}

	Map<String, SafeComponent> mapChildren;
	SafeComponent Parent;

	public SafeComposite(SafeComponent safeComponent, String myname) {
		mapChildren = new HashMap<String, SafeComponent>();
		Parent = safeComponent;
		
		name = myname;
	}

	public SafeComposite getParent() {
		return (SafeComposite) Parent;
	}

	public void addChild(String name, SafeComponent parentComponent) {
		mapChildren.put(name, parentComponent);
	}

	public void delete(String child) {
		mapChildren.remove(child);
	}

	public void updateChildren(Map<String, SafeComponent> mapChildren) {
		this.mapChildren = mapChildren;
	}

	public Map<String, SafeComponent> getChileren() {
		return mapChildren;
	}

}
